package status;

/**
 * 优先级只是增加了调度概率，并不一定按优先级执行
 */
public class TestPriority{
    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getName()+"优先级"+Thread.currentThread().getPriority());//默认5
        MyPriority myPriority = new MyPriority();
        Thread t1 = new Thread(myPriority);
        Thread t2 = new Thread(myPriority);
        Thread t3 = new Thread(myPriority);
        Thread t4 = new Thread(myPriority);
        Thread t5 = new Thread(myPriority);

        t1.start();//默认5

        t2.setPriority(4);
        t2.start();

        t3.setPriority(10);
        t3.start();

        t4.setPriority(7);
        t4.start();

        t5.setPriority(8);
        t5.start();
    }
}
class MyPriority implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"优先级"+Thread.currentThread().getPriority());
    }
}